package xj.graph2d.template.uml;

import xj.graph2d.AbstractModelListener;
import xj.graph2d.DrawShape;
import xj.graph2d.GraphNodeBase;
import xj.model.uml.Note;

public class UMLNotesModelListener extends AbstractModelListener {

  public UMLNotesModelListener() {
  }

  public UMLNotesModelListener(Object model, DrawShape shape) {
    super(model, shape);
  }

  @Override
  public void updateModel() {
    if (shape instanceof GraphNodeBase && model instanceof Note) {
      GraphNodeBase nnode = (GraphNodeBase) shape;
      Note nmodel = (Note) model;
      String text = nnode.getLabel();
      if (text != null) {
	nmodel.setText(text);
      }
    }
  }

  @Override
  public void updateShape() {
    if (shape instanceof GraphNodeBase && model instanceof Note) {
      GraphNodeBase nnode = (GraphNodeBase) shape;
      Note nmodel = (Note) model;
      String text = nmodel.getText();
      if (text != null) {
	nnode.setLabel(text);
      }
    }
  }

}
